package com.dhcc.bpm.modules.api.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.common.annotation.Log;
import com.dhcc.bpm.common.enums.BusinessType;
import com.dhcc.bpm.modules.api.entity.TransformProtocol;
import com.dhcc.bpm.modules.api.service.ITransformProtocolService;
import com.dhcc.bpm.modules.api.vo.TransformProtocolVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 协议转换表 控制器
 *
 * @author donghang
 * @since 2020-03-09
 */
@RestController
@AllArgsConstructor
@RequestMapping("bpm-api/transformprotocol")
@Api(value = "协议转换表", tags = "协议转换表接口")
public class TransformProtocolController extends BladeController {

	private ITransformProtocolService transformProtocolService;

	/**
	 * @Description 系统表详情
	 * @Author daina
	 * @Date 10:35 2020/3/26
	 * @param transformProtocol
	 * @return org.springblade.core.tool.api.R<com.dhcc.bpm.modules.api.entity.TransformProtocol>
	 **/
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入transformProtocol")
	@Log(title = "系统表详情", businessType = BusinessType.SELECT)
	@ApiLog("系统表详情")
	public R<TransformProtocol> detail(TransformProtocol transformProtocol) {
		TransformProtocol detail = transformProtocolService.getOne(Condition.getQueryWrapper(transformProtocol));
		return R.data(detail);
	}

	/**
	 * @Description 分页 协议转换表
	 * @Author daina
	 * @Date 10:35 2020/3/26
	 * @param transformProtocol
	 * @param query
	 * @return org.springblade.core.tool.api.R<com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.api.entity.TransformProtocol>>
	 **/
	@GetMapping("/list")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "分页", notes = "传入transformProtocol")
	@Log(title = "分页 协议转换表", businessType = BusinessType.SELECT)
	@ApiLog("分页 协议转换表")
	public R<IPage<TransformProtocol>> list(TransformProtocol transformProtocol, Query query) {
		IPage<TransformProtocol> pages = transformProtocolService.page(Condition.getPage(query), Condition.getQueryWrapper(transformProtocol));
		return R.data(pages);
	}

	/**
	 * @Description 自定义分页 协议转换表
	 * @Author daina
	 * @Date 10:35 2020/3/26
	 * @param transformProtocol
	 * @param query
	 * @return org.springblade.core.tool.api.R<com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.api.vo.TransformProtocolVO>>
	 **/
	@GetMapping("/page")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "自定义分页 协议转换表", notes = "传入transformProtocol")
	@Log(title = "自定义分页 协议转换表", businessType = BusinessType.SELECT)
	@ApiLog("自定义分页 协议转换表")
	public R<IPage<TransformProtocolVO>> page(TransformProtocolVO transformProtocol, Query query) {
		IPage<TransformProtocolVO> pages = transformProtocolService.selectTransformProtocolPage(Condition.getPage(query), transformProtocol);
		return R.data(pages);
	}

	/**
	 * @Description 新增 协议转换表
	 * @Author daina
	 * @Date 10:35 2020/3/26
	 * @param transformProtocol
	 * @return org.springblade.core.tool.api.R
	 **/
	@PostMapping("/save")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "新增", notes = "传入transformProtocol")
	@Log(title = "新增 协议转换表", businessType = BusinessType.INSERT)
	@ApiLog("新增 协议转换表")
	public R save(@Valid @RequestBody TransformProtocol transformProtocol) {
		return R.status(transformProtocolService.save(transformProtocol));
	}

	/**
	 * @Description 修改 协议转换表
	 * @Author daina
	 * @Date 10:36 2020/3/26
	 * @param transformProtocol
	 * @return org.springblade.core.tool.api.R
	 **/
	@PostMapping("/update")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "修改 协议转换表", notes = "传入transformProtocol")
	@Log(title = "修改 协议转换表", businessType = BusinessType.UPDATE)
	@ApiLog("修改 协议转换表")
	public R update(@Valid @RequestBody TransformProtocol transformProtocol) {
		return R.status(transformProtocolService.updateById(transformProtocol));
	}

	/**
	 * @Description 新增或修改 协议转换表
	 * @Author daina
	 * @Date 10:36 2020/3/26
	 * @param transformProtocol
	 * @return org.springblade.core.tool.api.R
	 **/
	@PostMapping("/submit")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "新增或修改 协议转换表", notes = "传入transformProtocol")
	@Log(title = "新增或修改 协议转换表", businessType = BusinessType.INSERT)
	@ApiLog("新增或修改 协议转换表")
	public R submit(@Valid @RequestBody TransformProtocol transformProtocol) {
		return R.status(transformProtocolService.saveOrUpdate(transformProtocol));
	}

	
	/**
	 * @Description 删除 协议转换表
	 * @Author daina
	 * @Date 10:36 2020/3/26
	 * @param ids
	 * @return org.springblade.core.tool.api.R
	 **/
	@PostMapping("/remove")
	@ApiOperationSupport(order = 7)
	@ApiOperation(value = "删除协议转换", notes = "传入ids")
	@Log(title = "删除协议转换", businessType = BusinessType.DELETE)
	@ApiLog("删除协议转换")
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.status(transformProtocolService.deleteLogic(Func.toLongList(ids)));
	}

	
}
